<template>
  <div class='sidebar'>
    <el-menu
      class="sidebar-list"
      :default-active="route"
      @open="handleOpen"
      @close="handleClose"
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b"
      router
      unique-opened>
      <el-menu-item index="/manage">
        <i class="el-icon-menu"></i>
        <span slot="title">首页</span>
      </el-menu-item>
      <el-submenu index="2">
        <template slot="title">
          <i class="el-icon-location"></i>
          <span>用户管理</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="/userlist">用户列表</el-menu-item>
          <el-menu-item index="/reportuser">举报用户</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
      <el-submenu index="3">
        <template slot="title">
          <i class="el-icon-location"></i>
          <span>主页管理</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="/homepagebanner">主页banner</el-menu-item>
          <el-menu-item index="/homepagerecommend">主页推荐</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
      <el-submenu index="4">
        <template slot="title">
          <i class="el-icon-location"></i>
          <span>话题管理</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="/topicbanner">话题banner</el-menu-item>
          <el-menu-item index="/topicmanagesub">话题管理</el-menu-item>
          <el-menu-item index="/dailyoptimal">每日优选</el-menu-item>
          <el-menu-item index="/hottopic">热门话题</el-menu-item>
          <el-menu-item index="/hashtag">话题标签</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
    </el-menu>
  </el-col>
  </div>
</template>

<script>
export default {
  name: 'sidebar',
  computed: {
    route() {
      let router = `/${this.$route.path.split('/')[1]}`;
      return router;
    }
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    }
  }
};
</script>

<style lang="less" scoped>
.sidebar {
  width: 100%;
  height: 100vh;
  .sidebar-list {
    height: 100%;
  }
}
</style>
